package com.meida.paotui.bus.provider.service.impl;

import com.meida.common.mybatis.base.service.impl.BaseServiceImpl;
import com.meida.common.mybatis.model.PageModel;
import com.meida.common.mybatis.model.ResultBody;
import com.meida.common.mybatis.query.CriteriaQuery;
import com.meida.common.security.OpenHelper;
import com.meida.common.utils.FlymeUtils;
import com.meida.paotui.bus.client.entity.BusMsgreceive;
import com.meida.paotui.bus.provider.mapper.BusMsgreceiveMapper;
import com.meida.paotui.bus.provider.service.BusMsgreceiveService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 用户消息关联表 实现类
 *
 * @author flyme
 * @date 2019-11-25
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class BusMsgreceiveServiceImpl extends BaseServiceImpl<BusMsgreceiveMapper, BusMsgreceive> implements BusMsgreceiveService {
    @Override
    public ResultBody getmsgList(PageModel model, String type) {
        Long userId=OpenHelper.getUserId();
        if(FlymeUtils.isEmpty(userId)){
            ResultBody.failed("请重新登陆！");
        }
        CriteriaQuery cq = new CriteriaQuery(model, BusMsgreceive.class);
        cq.select(BusMsgreceive.class, "*");
        cq.eq(BusMsgreceive.class,"receiveUserId", OpenHelper.getUserId());
        if(FlymeUtils.isNotEmpty(type)) {
            cq.eq(BusMsgreceive.class, "msgType", type);
        }
        if(FlymeUtils.isNotEmpty(type)) {
            cq.eq(BusMsgreceive.class, "msgType", type);
        }
        return basePageList(cq);
    }
    @Override
    public ResultBody getSysmsg(PageModel model) {
        CriteriaQuery cq = new CriteriaQuery(model, BusMsgreceive.class);
        cq.select(BusMsgreceive.class, "*");
        cq.eq(BusMsgreceive.class, "msgType", 0);
        return basePageList(cq);
    }


}
